<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%><%@   page   import="com.jzhao.control.*,
com.jzhao.jpre.format.*,
com.jzhao.jpre.base.*,
com.jzhao.control.model.*,
com.jzhao.control.model.dao.*,
					 java.util.*"%><%
					 
String useAcc = request.getParameter("UserId");
String sessionId = request.getParameter("SessionId");

RemoterAccDao	remoterAccDao = (RemoterAccDao)Assembler.getInstance("remoterAccDao");
RemoterLoginlogDao remoterLoginlogDao = (RemoterLoginlogDao)Assembler.getInstance("remoterLoginlogDao");
RemoterAccfriendsDao remoterAccfriendsDao = (RemoterAccfriendsDao)Assembler.getInstance("remoterAccfriendsDao");


RemoterAcc remoterAcc = remoterAccDao.selectByAccId(useAcc);
RemoterLoginlog remoterLoginlog  =remoterLoginlogDao.getRemoterLoginlogBySessionId(sessionId);

Map result = new HashMap();

if(remoterAcc != null && remoterLoginlog != null && remoterLoginlog.getStatus() == 1){
	List list = remoterAccfriendsDao.selectUserFriendsAcc(remoterAcc.getId());
	
	//JSONObject jsonObject = JSONObject.fromObject( resultMap );  
	//result = jsonObject.toString();//200
	
	List list2 = new ArrayList();
	for(Iterator it =list.iterator();it.hasNext();){
		Map one = (Map)it.next();
		
		
		
		com.jzhao.control.Friends friends = new Friends();
		friends.setUserAcc(one.get("USER_ACC").toString());
		friends.setStatus(one.get("STATUS").toString());
		friends.setType(one.get("TYPE").toString());
		friends.setRelationTime((Date)one.get("RELATION_TIME"));
		
		
		list2.add(friends);
	}
	
	result.put("rescode".toUpperCase(),"00");
	result.put("resmsg".toUpperCase(),"查询成功");
	result.put("size".toUpperCase(),list.size());
	result.put("friends".toUpperCase(),list2);
}else{
	result.put("rescode".toUpperCase(),"01");
	result.put("resmsg".toUpperCase(),"查询失败");
	List list = new ArrayList();
	result.put("size".toUpperCase(),list.size());
	result.put("friends".toUpperCase(),list);
}
//http://yjhexy.iteye.com/blog/681067
net.sf.json.JsonConfig jsonConfig = new  net.sf.json.JsonConfig();
jsonConfig.registerJsonValueProcessor(java.util.Date.class, new com.jzhao.control.json.DateJsonValueProcessor("yyyy-MM-dd HH:mm:ss"));
net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject( result,jsonConfig );
out.print(jsonObject.toString());




%>